package mysql

import "gorm.io/gorm"

type Order struct { //订单表
	gorm.Model
	UserId  int     `gorm:"type:int(11);not null;comment:'用户id'"`
	Pride   float64 `gorm:"type:decimal(10,2);not null;comment:'充值金额'"`
	OrderSn string  `gorm:"type:varchar(100);not null;comment:'订单编号'"`
	Status  int8    `gorm:"type:tinyint;default:1;comment:'订单状态:0-待支付,1-已支付,2-已取消,3-已完成'"`
	PayType int8    `gorm:"type:tinyint;default:1;comment:'支付方式:0-微信,1-支付宝'"`
}
type User struct {
	gorm.Model
	Level   int  `gorm:"type:int(11);not null;comment:'会员等级'"`
	Amount  int  `gorm:"type:int(11);not null;comment:'账户余额'"`
	Times   int  `gorm:"type:int(11);not null;comment:'剩余时长'"`
	Checked int8 `gorm:"type:tinyint;default:1;comment:'会员状态:0-已过期,1-未过期'"`
}

// 创建订单表
func (o *Order) CreateOrder() error {
	return DB.Create(&o).Error
}

// 创建会员信息表
func (u *User) CreateUser() error {
	return DB.Create(&u).Error
}
